// 价牌模板管理接口
import { default as request, download } from '@/utils/request'
// import { getUser, getToken } from '@/utils/auth'
import qs from 'qs'

export function getTemplateList(data) {
  return request({
    url: '/template/page/get',
    method: 'post',
    data
  })
}

export function getPriceList(data) {
  return request({
    url: '/price/template/get',
    method: 'post',
    data
  })
}

export function getSectionBasedPriceList(data) {
  return request({
    url: '/sectionBased/price/page',
    method: 'post',
    data
  })
}

// 添加价牌模板
export function addPrice(data) {
  return request({
    url: '/price/template/add/type/' + data.priceType,
    method: 'post',
    data:data
  })
}

// 修改价牌模板
export function putPrice(data) {
  return request({
    url: '/price/template/save',
    method: 'post',
    data
  })
}

// 删除价牌模板
export function delPrice(data) {
  return request({
    url: '/price/template/del/' + data.priceId,
    method: 'delete',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data)
  })
}

// 导出价格修改列表数据
export function exportSectionBasedPriceList(data) {
  return request({
    url: '/sectionBased/price/download',
    method: 'post',
    data,
    responseType: 'arraybuffer'
  }).then(res => {
    return download(res)
  })
}

// 批量修改价格
export function putSectionBasedPrice(data, otaId) {
  return request({
    url: `/sectionBased/price/edit/${otaId}`,
    method: 'post',
    data
  })
}
